package com.financing.platform.dao.impl;

import java.util.List;
import java.util.Map;

import com.financing.platform.dao.impl.BaseDaoImpl;
import com.financing.platform.dao.IFpFundInfoDao;
import com.financing.platform.dto.FpFundInfoDTO;
import com.financing.platform.util.SqlName;

import java.sql.SQLException;
import java.util.Collections;

import org.springframework.stereotype.Repository;

/**
 * @Description:实现类
 * @author caojiayao
 * @version 1.0
 * @created 
 */
@Repository("fpFundInfo")
public class FpFundInfoDaoImpl extends BaseDaoImpl implements IFpFundInfoDao {
	
	@Override
	public FpFundInfoDTO getFpFundInfo(FpFundInfoDTO dto) {
		try{
			return (FpFundInfoDTO)this.sqlMapClient.queryForObject(SqlName.fpFundInfo,dto);
		} catch (SQLException e) {
			log.error("get fpFundInfo error:",e);
			return null;
		}
	}
	
	
	@Override
	public Integer insertFpFundInfo(FpFundInfoDTO dto) {
		try {
		     return (Integer) this.sqlMapClient.insert(SqlName.insertFpFundInfo,dto);
		} catch (SQLException e) {
			log.error("add fpFundInfo error:",e);
			return 0;
		}
	}

	
	@Override
	public Integer updateFpFundInfo(Map map) {
		try {
			return (Integer) this.sqlMapClient.update(SqlName.updateFpFundInfo, map);
		} catch (SQLException e) {
			this.log.error("update fpFundInfo error 1!",e);
			return 0;
		}
	}
	
	@Override
	public Integer delFpFundInfo(Integer id) {
		try{
			 return (Integer) this.sqlMapClient.delete(SqlName.delFpFundInfo, id);
		} catch (SQLException e) {
			log.error("del fpFundInfo error:",e);
			return 0;
		}
	}
	
	@Override
	public List<FpFundInfoDTO> listFpFundInfo(FpFundInfoDTO dto) {
		try {
			return (List<FpFundInfoDTO>)this.sqlMapClient.queryForList(SqlName.listFpFundInfo, dto);
		} catch (SQLException e) {
			log.error("Query fpFundInfo note list error !", e);
			return Collections.emptyList();
		}
	}
	
	
	public Integer countFpFundInfo(FpFundInfoDTO dto){
		try {
			return (Integer)this.sqlMapClient.queryForObject(SqlName.countFpFundInfo, dto);
		} catch (SQLException e) {
			log.error("Query fpFundInfo note list error !", e);
			return 0;
		}
	}
	
	
	public List<FpFundInfoDTO> listFpFundInfoByCompanyId(String CompanyId){
		try {
			return (List<FpFundInfoDTO>)this.sqlMapClient.queryForList(SqlName.listFpFundInfoByCompanyId, CompanyId);
		} catch (SQLException e) {
			log.error("Query listFpFundInfoByCompanyId error !", e);
			return Collections.emptyList();
		}
	}
	
	public List<FpFundInfoDTO> listFpFundInfoByManagerId(String ManagerId){
		try {
			return (List<FpFundInfoDTO>)this.sqlMapClient.queryForList(SqlName.listFpFundInfoByManagerId, ManagerId);
		} catch (SQLException e) {
			log.error("Query listFpFundInfoByCompanyId error !", e);
			return Collections.emptyList();
		}
	}


	@Override
	public Map<String, Object>  queryFundInfoNameById(String id) {
		try {
			return (Map<String, Object>)this.sqlMapClient.queryForObject(SqlName.queryFundInfoNameById, id);
		} catch (SQLException e) {
			log.error("get queryFundInfoNameById error:",e);
			return null;
		}
	}
	
}
